// pages/consume/consume.js
const {
    imgConfig,
    config
} = require('../../utils/config.js')
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        imgUrl: `${imgConfig}`,
        statusBarHeight: app.globalData.statusBarHeight,
        total:0,
        completion:0,
        stuCourses:0
        
    },
    back: function () {
        wx.navigateBack({});
    },
    /**
     * 获取缴费记录与课程信息
     */
    getStuConsume() {
        var that = this
        console.log(app.globalData.userInfo);
        wx.request({
            url: `${config}/wechat/wxConsume/getStuConsume`,
            data: {
                majorId: app.globalData.userInfo.majorId,
                stuId: app.globalData.userInfo.id
            },
            success(resp) {
                console.log(resp)
                if (resp.data.code == 0) {
                  console.log(resp.data);
                    that.setData({
                        total: resp.data.total.toFixed(2),
                        stuConsume: resp.data.stuConsume,
                        expense: resp.data.expense.toFixed(2),
                        completion: resp.data.map.completion,
                        courseList: resp.data.map.stuCourseChapterList,
                        clockChapterCount: resp.data.map.clockChapterCount,
                        courseCount: resp.data.map.courseCount,
                        chapterCount: resp.data.map.chapterCount,
                        stuCourses:(resp.data.allConSum[0].allconnsum),
                    })
                }
            }
        })


    },
    
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.getStuConsume()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {
       
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})